home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 February: Tool Chest / Dev.CD Feb 94.toast / Tool Chest / Development Platforms / MPW Related / MPW Interfaces / CIncludes / CursorCtl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  5.0 KB  |  119 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CursorCtl.h
  3.  
  4.     Copyright:    © 1983-1993 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Version:    System 7.1 for ETO #11
  8.     Created:    Tuesday, March 30, 1993 18:00
  9.  
  10. */
  11.  
  12. #ifndef __CURSORCTL__
  13. #define __CURSORCTL__
  14.  
  15. enum {HIDDEN_CURSOR,I_BEAM_CURSOR,CROSS_CURSOR,PLUS_CURSOR,WATCH_CURSOR,
  16.     ARROW_CURSOR};
  17. typedef unsigned char Cursors;
  18.  
  19. struct Acur {
  20.     short n;        /*Number of cursors ("frames of film")*/
  21.     short index;    /* Next frame to show <for internal use>*/
  22.     short frame1;    /*'CURS' resource id for frame #1*/
  23.     short fill1;    /*<for internal use>*/
  24.     short frame2;    /*'CURS' resource id for frame #2*/
  25.     short fill2;    /*<for internal use>*/
  26.     short frameN;    /*'CURS' resource id for frame #N*/
  27.     short fillN;    /*<for internal use>*/
  28. };
  29.  
  30. typedef struct Acur acur,*acurPtr,**acurHandle;
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. pascal void InitCursorCtl(acurHandle newCursors);
  36. /*
  37.     Initialize the CursorCtl unit. This should be called once prior to calling
  38.     RotateCursor or SpinCursor. It need not be called if only Hide_Cursor or
  39.     Show_Cursor are used. If NewCursors is NULL, InitCursorCtl loads in the
  40.     'acur' resource and the 'CURS' resources specified by the 'acur' resource
  41.     ids.  If any of the resources cannot be loaded, the cursor will not be
  42.     changed.
  43.     
  44.     The 'acur' resource is assumed to either be in the currently running tool or
  45.     application, or the MPW Shell for a tool, or in the System file.  The 'acur'
  46.     resource id must be 0 for a tool or application, 1 for the Shell, and 2 for
  47.     the System file.
  48.     
  49.     If NewCursors is not NULL, it is ASSUMED to be a handle to an 'acur' formatted
  50.     resource designated by the caller and it will be used instead of doing a
  51.     GetResource on 'acur'. Note, if RotateCursor or SpinCursor are called without
  52.     calling InitCursorCtl, then RotateCursor and SpinCursor will do the call for
  53.     the user the first time it is called.  However, the possible disadvantage of
  54.     using this technique is that the resource memory allocated may have
  55.     undesirable affect (fragmentation?) on the application. Using InitCursorCtl
  56.     has the advantage of causing the allocation at a specific time determined by
  57.     the user.
  58.     
  59.     Caution: InitCursorCtl MODIFIES the 'acur' resource in memory.    Specifically,
  60.     it changes each FrameN/fillN integer pair to a handle to the corresponding
  61.     'CURS' resource also in memory.  Thus if NewCursors is not NULL when
  62.     InitCursorCtl is called, the caller must guarantee NewCursors always points to
  63.     a "fresh" copy of an 'acur' resource.  This need only be of concern to a
  64.     caller who wants to repeatly use multiple 'acur' resources during execution of
  65.     their programs.
  66. */
  67.  
  68. pascal void RotateCursor(long counter); 
  69. /*
  70.     RotateCursor is called to rotate the "I am active" "beach ball" cursor, or to
  71.     animate whatever sequence of cursors set up by InitCursorCtl. The next cursor
  72.     ("frame") is used when Counter % 32 = 0 (Counter is some kind of incrementing
  73.     or decrementing index maintained by the caller). A positive counter sequences
  74.     forward through the cursors (e.g., it rotates the "beach ball" cursor
  75.     clockwise), and a negative cursor sequences through the cursors backwards
  76.     (e.g., it rotates the "beach ball" cursor counterclockwise).  Note,
  77.     RotateCursor just does a Mac SetCursor call for the proper cursor picture.
  78.       It is assumed the cursor is visible from a prior Show_Cursor call.
  79. */
  80.  
  81. pascal void SpinCursor(short increment);
  82. /*
  83.     SpinCursor is similar in function to RotateCursor, except that instead of
  84.     passing a counter, an Increment is passed an added to a counter maintained
  85.     here.  SpinCursor is provided for those users who do not happen to have a
  86.     convenient counter handy but still want to use the spinning "beach ball"
  87.     cursor, or any sequence of cursors set up by InitCursorCtl.  A positive 
  88.     increment sequences forward through the curos (rotating the "beach ball"
  89.     cursor clockwise), and a negative increment sequences backward through the
  90.     cursors (rotating the "beach ball" cursor counter-clockwise).  A zero value
  91.     for the increment resets the counter to zero.  Note, it is the increment, and
  92.     not the value of the counter that determines the sequencing direction of the
  93.     cursor (and hence the spin direction of the "beach ball" cursor).
  94. */
  95.  
  96. pascal void Hide_Cursor(void);
  97. /*
  98.     Hide the cursor if it is showing.This is this unit's call to the Mac
  99.     HideCursor routine.Thus the Mac cursor level is decremented by one when this
  100.     routine is called.
  101. */
  102.  
  103. pascal void Show_Cursor(Cursors cursorKind);
  104. /*
  105.     Increment the cursor level, which may have been decremented by Hide_Cursor,
  106.     and display the specified cursor if the level becomes 0 (it is never
  107.     incremented beyond 0).The CursorKind is the kind of cursor to show.  It is
  108.     one of the values HIDDEN_CURSOR, I_BEAM_CURSOR, CROSS_CURSOR, PLUS_CURSOR,
  109.     WATCH_CURSOR, and ARROW_CURSOR. Except for HIDDEN_CURSOR, a Mac SetCursor is
  110.     done for the specified cursor prior to doing a ShowCursor.    HIDDEN_CURSOR just
  111.     causes a ShowCursor call.  Note, ARROW_CURSOR will only work correctly if
  112.     there is already a grafPort set up pointed to by 0(A5).
  113. */
  114. #ifdef __cplusplus
  115. }
  116. #endif
  117.  
  118. #endif
  119.